package com.ysx.controller;

import com.ysx.bean.ScottRoleBean;
import com.ysx.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/role")
public class RoleController {


    @Autowired
    private RoleService service;

    // http://localhost:8080/attendance-service/role/find?id=800100
    @RequestMapping("/find")
    @ResponseBody
    public Map<String,Object> findById(Integer id){
        Map<String,Object> map = new HashMap();
        ScottRoleBean bean = service.findById(id);

        map.put("code",200);
        map.put("message","success");
        map.put("data",bean);
        return map;
    }
    @RequestMapping(value = "/add.do",method = RequestMethod.POST)
    @ResponseBody
    public Map<String,Object> add(@RequestBody ScottRoleBean bean){
        Map<String,Object> map = new HashMap();
        service.add(bean);

        map.put("code",200);
        map.put("message","success");
        map.put("data",null);
        return map;
    }

}
